Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
How do I "clear" my timer using my clear button?

I am new to javascript. I am trying to clear my timer value on clcking the"clear" button.I tried to use the variable"sec" from myTimer function, but it is not working. Any suggestions? Help is appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

the document.getElementsByTagName gets the button and runs the function when clicked.

let timer;
let increment = 0;

timer = setInterval(() => increment++ , 1000)

//gets the button element and clears timer when clicked
document.getElementsByTagName("button").onclick = function() {
    clearInterval(timer)
}
about 4 years ago · Juan Pablo Isaza Report

0

let count = 0
let myTimer;

// set timer
myTimer = setInterval(() => count = count + 1 , 1000)

// clear timer
clearInterval(myTimer)

Show the code of your timer so that I can describe the solution in more detail

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!